<?php
/**
 * IG_Report_Db
 * @author maomao.thx@gmail.com
 * @copyright Copyright (c) 2009 Green Shore (http://www.iwgame.com)
 * @version $Id: Db.php 1021 2011-11-09 01:06:33Z mmxie $
 */
class IG_Report_Db extends IG_Report_Abstract
{
    public function __construct($options, $queryString = '', $params = array())
    {
        $this->_adapter = Zend_Db::factory($options['adapter'], $options);

        $this->_queryString = $queryString;

        $queryParams = array();
        if (is_array($params)) {
            foreach ($params as $k => $v) {
                if (isset($v['value'])) {
                    $queryParams[$k] = $v['value'];
                } else {

                }
            }
        }
        if($queryString != '') {
            $this->_data = $this->query(array('cmd' => $queryString, 'params' => $queryParams));
        }
    }

    public function query($params = array())
    {
        return $this->_adapter->query($params['cmd'], $params['params'])->fetchAll();
    }

    public function insert($target, $data = array())
    {
        return $this->_adapter->insert($target, $data);
    }
}